package com.yanq.liancar.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.vondear.rxtool.RxActivityTool;
import com.vondear.rxtool.view.RxToast;
import com.yanq.liancar.R;
import com.yanq.liancar.activity.base.BaseToolbarActivity;
import com.yanq.liancar.bean.UserBean;
import com.yanq.liancar.util.Utils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class SmallBMySetActivity extends BaseToolbarActivity {
    @BindView(R.id.ll_tv_Account)
    LinearLayout llTvAccount;
    @BindView(R.id.ll_tv_Contacts)
    LinearLayout llTvContacts;
    @BindView(R.id.ll_tv_About)
    LinearLayout llTvAbout;
    @BindView(R.id.set_tv_cache)
    TextView setTvCache;
    @BindView(R.id.ll_tv_Clear)
    LinearLayout llTvClear;
    @BindView(R.id.ll_tv_Agreement)
    LinearLayout ll_tv_Agreement;
    @BindView(R.id.ll_tv_Statement)
    LinearLayout llTvStatement;
    @BindView(R.id.set_tv_SignOut)
    TextView setTvSignOut;
    private int where;  //1:小C   2：小B
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_smallbmyset);
        Utils.setStatusBar(this, true,false);
        ButterKnife.bind(this);
        mTvTitle.setText("设置");
        where=getIntent().getExtras().getInt("where");
        if (where!=1){
            llTvAccount.setVisibility(View.GONE);
            ll_tv_Agreement.setVisibility(View.VISIBLE);
        }
    }

    @OnClick({R.id.ll_tv_Account, R.id.ll_tv_Contacts, R.id.ll_tv_About, R.id.ll_tv_Clear, R.id.ll_tv_Statement, R.id.set_tv_SignOut,R.id.ll_tv_Agreement})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ll_tv_Account:        //账号绑定
                RxActivityTool.skipActivity(mContext, SmallBBindAccountActivity.class);
                break;
            case R.id.ll_tv_Contacts:
                RxActivityTool.skipActivity(mContext, ContactUsActivity.class);
                break;
            case R.id.ll_tv_About:      //关于我们
                RxActivityTool.skipActivity(mContext, SmallBAboutActivity.class);
                break;
            case R.id.ll_tv_Clear:
                break;
            case R.id.ll_tv_Statement:      //法律声明
                RxActivityTool.skipActivity(mContext, SmallBStatementActivity.class);
                break;
            case R.id.set_tv_SignOut:
                if (where==1){
                    if (!TextUtils.isEmpty(UserBean.getcToken(mContext))){
                        UserBean.removecToken(mContext);
                        RxActivityTool.finishAllActivity();
                        RxActivityTool.skipActivity(mContext, SelectActivity.class);
                    }else {
                        RxToast.error("您还未登录");
                    }
                }else {
                    if (!TextUtils.isEmpty(UserBean.getbToken(mContext))){
                        UserBean.removeBToken(mContext);
                        RxActivityTool.finishAllActivity();
                        RxActivityTool.skipActivity(mContext, SelectActivity.class);
                    }else {
                        RxToast.error("您还未登录");
                    }
                }

                break;
            case R.id.ll_tv_Agreement:
                Bundle bundle=new Bundle();
                bundle.putInt("type",2);
                RxActivityTool.skipActivity(this, ProtocolListActivity.class,bundle);
                break;
        }
    }
}
